#pragma once
#include "Protocol.hpp"
#include "Factory.hpp"
using namespace protocol_ns;

Response Cal(Request req)
{
    Response res = Factory::CreateResponse();
    switch (req._oper)
    {
    case '+':
        res._result = req._leftOperNum + req._rightOperNum;
        break;
    case '-':
        res._result = req._leftOperNum - req._rightOperNum;
        break;
    case '*':
        res._result = req._leftOperNum * req._rightOperNum;
        break;
    case '/':
        if (req._rightOperNum == 0)
            res._code = 1;
        else
            res._result = req._leftOperNum / req._rightOperNum;
        break;
    case '%':
        if (req._rightOperNum == 0)
            res._code = 1;
        else
            res._result = req._leftOperNum % req._rightOperNum;
        break;
    default:
        res._code = 2;
        break;
    }
    return res;
}
